/**
 * @file
 * Tests for multiset comparison.
 * Note that tests have been written for int type only, but the understanding is that if the
 * == operator works for a given data type, the comparison will work.
 */

#include <iostream>
#include <map>

#include <gtest/gtest.h>

#include "multimap_comparison.h"

/**
 *  Tests for comparison of multimaps.
 */
TEST(AssociativeContainerComparison, MultiMapComparison)
{
  std::multimap<int,int> data1;
  data1.insert(std::pair<int,int>(4, 2));
  data1.insert(std::pair<int,int>(5, 1));
  data1.insert(std::pair<int,int>(2, 7));
  data1.insert(std::pair<int,int>(3, 8));
  data1.insert(std::pair<int,int>(3, 3));  
  data1.insert(std::pair<int,int>(3, 3));
  data1.insert(std::pair<int,int>(1, 5));
  data1.insert(std::pair<int,int>(2, 4));
  data1.insert(std::pair<int,int>(3, 3));


  std::multimap<int,int> data2;
  data2.insert(std::pair<int,int>(2, 4));
  data2.insert(std::pair<int,int>(4, 2));
  data2.insert(std::pair<int,int>(5, 1));
  data2.insert(std::pair<int,int>(3, 3));
  data2.insert(std::pair<int,int>(1, 5));
  data2.insert(std::pair<int,int>(2, 7));
  data2.insert(std::pair<int,int>(3, 8));
  data2.insert(std::pair<int,int>(3, 3));  
  data2.insert(std::pair<int,int>(3, 3));

  std::multimap<int,int> data3;
  data3.insert(std::pair<int,int>(1, 5));
  data3.insert(std::pair<int,int>(2, 4));
  data3.insert(std::pair<int,int>(3, 3));
  data3.insert(std::pair<int,int>(4, 2));
  data3.insert(std::pair<int,int>(5, 1));
  data3.insert(std::pair<int,int>(6, 6));
  data3.insert(std::pair<int,int>(5, 1));
  data3.insert(std::pair<int,int>(6, 6));
  data3.insert(std::pair<int,int>(5, 1));
  data3.insert(std::pair<int,int>(6, 6));

  // The == operator for multimaps should do an element by element 
  // comparison and must evaluate these two to be unequal. 
  // Semantic compare should evaluate them to be equal
  // as order does not matter.
  EXPECT_TRUE(multimap_compare(data1,data2));
  //  Transitive counterpart
  EXPECT_TRUE(multimap_compare(data2,data1));

  // Not equal 
  EXPECT_FALSE(multimap_compare(data1, data3));
  // Transitive counterpart
  EXPECT_FALSE(multimap_compare(data3, data1));     
}
